<?php
$user_folder   = $this->session->userdata('image_folder');
$aImage        = get_filenames(UPLOAD_FOLDER_URL . ADVERTISE_IMAGE_URL);
$temp_img_path = UPLOAD_FOLDER_URL . 'public/' . $user_folder . '/uploaded/';
$aTempImage    = upload_modal_get($temp_img_path);
?>

<div class="modal fade" tabindex="-1" role="dialog" id="modal-image" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">Chọn hình ảnh</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-10 col-md-offset-2 col-xs-12">
                        <form id="frm-upload-img" method="post" action="<?php echo admin_page_url('hinh-anh/tai-len'); ?>" enctype="multipart/form-data">
                            <input type="hidden" name="w_case" value="advertise" />
                            <div class="form-group col-md-7 col-xs-12">
                                <div class="input-group">
                                    <input type="file" name="userfile" class="form-control" />
                                    <span class="input-group-btn">
                                        <button id="btn-change-img" class="btn btn-primary">
                                            <i class="glyphicon glyphicon-arrow-up"></i>
                                            Tải lên
                                            <span class="percent hidden">0%</span>
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="col-md-12 col-xs-12" id="image-set" data-url="<?php echo admin_page_url('/hinh-anh/xoa'); ?>">
                        <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đã tải lên</p>
                        <ul id="image-temp-upload" class="image-list clearPad">
                            <li class="hidden" id="advertise-temp-block">
                                <a href="#" class="thumbnail img-block-edit advertise-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-name='' data-folder='uploaded/'>
                                    <img class="media-object" src="" />
                                </a>
                            </li>
                            <?php foreach($aTempImage as $img) { ?>
                            <li>
                                <a href="<?php echo upload_raw($img, $user_folder); ?>" class="thumbnail img-block-edit advertise-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='uploaded/' data-name='<?php echo $img; ?>' >
                                    <img class="media-object" src="<?php echo upload_raw($img, $user_folder, false, true); ?>" />
                                </a>
                            </li>
                            <?php } ?>
                        </ul>
                        <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đang được sử dụng</p>
                        <ul class="image-list clearPad">
                            <?php foreach($aImage as $img) { ?>
                            <li>
                                <a href="#" class="thumbnail img-block-edit advertise-img-block " data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-name='<?php echo $img; ?>' data-folder='<?php echo ADVERTISE_IMAGE_URL; ?>'>
                                    <img class="media-object" src="<?php echo advertise_upload($img); ?>" />
                                </a>
                            </li>
                            <?php } ?>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>